<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<p>Check you can't drag into a data URL</p>
<div><span id="dragme">hello</span></div>
<iframe id="target" srcdoc='<body contenteditable="true"></body>'></iframe>
<script>
var target = document.getElementById("target");
var t = async_test('Drag-And-Drop to Data URL');

window.addEventListener('load', t.step_func(() => {
    if (!window.eventSender)
        throw new Error('This test requires eventSender.');

    // Drag 'hello'
    dragDropIt();
}));

function dragDropIt() {
    var dragMe = document.getElementById("dragme");
    window.getSelection().selectAllChildren(dragMe);
    var x = dragMe.offsetLeft + 10;
    var y = dragMe.offsetTop + dragMe.offsetHeight / 2;
    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();

    eventSender.leapForward(500);
    var framex = target.offsetLeft + 10;
    var framey = target.offsetTop + target.offsetHeight / 2;
    eventSender.mouseMoveTo(framex, framey);
    setTimeout(dropIt, 0);
}

function dropIt() {
    // Drop it off to the frame
    eventSender.mouseUp();
    assert_equals(target.contentDocument.body.outerHTML, '<body contenteditable="true"></body>');
    t.done();
}
</script>
